import React, {useState} from 'react'
import { Button } from 'antd';
import { bindActionCreators } from "redux"
import { actions } from "./model";
import { connect } from "react-redux"

 function Login({login}) {
     const [username, setUsername] = useState("")
     const [password, setPassword] = useState("")

     function getLogin() {
        login({username, password})
     }

  return (
    <div>
        <div>
            用户名：<input value={username} onChange={(e) => {setUsername(e.target.value)}} />
        </div>
        <div>
            密码<input value={password} onChange={(e) => {setPassword(e.target.value)}} />
        </div>
        <div> <Button type='primary' onClick={getLogin} >登录</Button> </div>
    </div>
  )
}
export default connect(
    ({userStore}) => ({userStore}), 
    dispath => bindActionCreators(actions, dispath)
)(Login)
